﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace project3
{
    class Program
    {
        static void Main(string[] args)
        {
            // 注意此处不能使用View,因为它不能对子节点进行管理操作
            ViewGroup root = new ViewGroup("root");
            root.Add(new Button("Button 1"));
            root.Add(new Button("Button 2"));
            ViewGroup viewgroup = new ViewGroup("ViewGroup X");

            viewgroup.Add(new Button("Button X 1"));
            viewgroup.Add(new Button("Button X 2"));
            viewgroup.Add(new LinearLayout("LinerarLayout X 1"));
            viewgroup.Add(new LinearLayout("LinerarLayout X 2"));
            root.Add(viewgroup);

            root.Add(new LinearLayout("LinearLayout 1"));

            // Add and remove a leaf
            Button l = new Button("Button3");
            //l.Add(new Leaf("xxxxxx"));    //Compiling Error!!!
            root.Add(l);
            root.Remove(l);

            // Recursively display nodes
            root.Display(0);

            Console.ReadLine();
        }
    }
}
